/*
 * @lc app=leetcode.cn id=2103 lang=csharp
 *
 * [2103] 环和杆
 */

// @lc code=start
public class Solution {
    public int CountPoints(string rings) {
        int[] state = new int[10];
        int length = rings.Length;
        
        for (int i = 0; i < length; i += 2)
        {
            int pos = rings[i+1] - '0';
            char color = rings[i];
            
            if (color == 'R')
            {
                state[pos] |= 1;
            }
            else if (color == 'G')
            {
                state[pos] |= 2;
            }
            else
            {
                state[pos] |= 4;
            }
        }
        
        int ans = 0;
        for (int i = 0; i <= 9; i++)
        {
            ans += state[i] == 7 ? 1 : 0;
        }
        return ans;
    }
}
// @lc code=end

